Time and logarithmic scales
An axis in LiveCharts always works with double values. To plot dates, durations or a logarithmic scale, the data is
turned into a number when it is mapped, and the axis turns that number back into a label. LiveCharts includes an axis
for each case: DateTimeAxis and TimeSpanAxis read the values as ticks, and LogarithmicAxis reads them as the
exponent of a base. This article covers only what these axes change; for the rest of the axis properties see the
axes article.
This article highlights the most used features. Every property is listed in the API explorer: DateTimeAxis, TimeSpanAxis, LogarithmicAxis, DateTimePoint and TimeSpanPoint.
Date time axis
A DateTimePoint has a DateTime and a Value. Its X coordinate is DateTime.Ticks and its Y coordinate is the
value; a null value leaves a gap. A DateTimeAxis on the X axis turns the ticks back into dates for the labels and
the tooltips.

using System;
using System.Windows.Forms;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.WinForms;
#pragma warning disable IDE1006 // Naming Styles
namespace WinFormsSample.Axes.DateTimeScaled;
public partial class View : UserControl
{
private readonly CartesianChart cartesianChart;
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var values = new DateTimePoint[]
{
new() { DateTime = new DateTime(2021, 1, 1), Value = 3 },
new() { DateTime = new DateTime(2021, 1, 2), Value = 6 },
new() { DateTime = new DateTime(2021, 1, 3), Value = 5 },
new() { DateTime = new DateTime(2021, 1, 4), Value = 3 },
new() { DateTime = new DateTime(2021, 1, 5), Value = 5 },
new() { DateTime = new DateTime(2021, 1, 6), Value = 8 },
new() { DateTime = new DateTime(2021, 1, 7), Value = 6 }
};
static string Formatter(DateTime date) => date.ToString("MMMM dd");
var series = new ISeries[]
{
new ColumnSeries<DateTimePoint> { Values = values }
};
var xAxis = new DateTimeAxis(TimeSpan.FromDays(1), Formatter);
cartesianChart = new CartesianChart
{
Series = series,
XAxes = [xAxis],
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
}
}
In code, the constructor takes the unit and the function that formats each label:
Series = new ISeries[]
{
new ColumnSeries<DateTimePoint>
{
Values = new DateTimePoint[]
{
new(new DateTime(2021, 1, 1), 3),
new(new DateTime(2021, 1, 2), 6),
new(new DateTime(2021, 1, 3), 5)
}
}
};
XAxes = new[]
{
new DateTimeAxis(TimeSpan.FromDays(1), date => date.ToString("MMMM dd")) // mark
};
The unit
The unit of a DateTimeAxis is the distance between two consecutive points, one day in the sample above. The axis
uses it twice:
UnitWidthis set to the unit, in ticks. Series drawn with bars, such as columns, candlesticks and boxes, take the width of each bar from it, so with the defaultUnitWidthof1a bar would be one tick wide.MinStepis set to the unit, so the axis never draws two labels closer than one unit. The step is calculated in units too: 1, 2, 5, 10, 20 days and so on in the sample. SetForceStepToMintotrueto draw a label on every unit.
Pick the unit that matches your data: TimeSpan.FromHours(1) for hourly points, or an average such as
TimeSpan.FromDays(30.4375) for months and TimeSpan.FromDays(365.25) for years, since months and years do not have
a fixed length.
Because the values are ticks, the limits of the axis are ticks too, for example
MinLimit = new DateTime(2021, 1, 1).Ticks. The
financial series
article shows the same axis with candlesticks.
Dates in your own types
DateTimePoint is optional. Any type works when its mapper returns the ticks as the X coordinate. A DateTimeAxis is
an Axis with UnitWidth, MinStep and Labeler already set, so a plain Axis with the same properties works the
same way; the AsDate() extension in the LiveChartsCore namespace converts the double back into a DateTime:
Series = new ISeries[]
{
new LineSeries<Sale>
{
Values = sales,
Mapping = (sale, index) => new(sale.Date.Ticks, sale.Total) // mark
}
};
XAxes = new[]
{
new Axis
{
UnitWidth = TimeSpan.FromDays(1).Ticks, // mark
MinStep = TimeSpan.FromDays(1).Ticks, // mark
Labeler = value => value.AsDate().ToString("MMM dd") // mark
}
};
See mappers for more about mapping your own types.
Time span axis
TimeSpanPoint and TimeSpanAxis do the same for durations: the X coordinate is TimeSpan.Ticks, and the
constructor of the axis takes the unit and a Func<TimeSpan, string> that formats each label. This sample uses a unit
of one millisecond: new TimeSpanAxis(TimeSpan.FromMilliseconds(1), value => $"{value:fff}ms").

using System;
using System.Windows.Forms;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.WinForms;
#pragma warning disable IDE1006 // Naming Styles
namespace WinFormsSample.Axes.TimeSpanScaled;
public partial class View : UserControl
{
private readonly CartesianChart cartesianChart;
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var values = new TimeSpanPoint[]
{
new() { TimeSpan = TimeSpan.FromMilliseconds(1), Value = 10 },
new() { TimeSpan = TimeSpan.FromMilliseconds(2), Value = 6 },
new() { TimeSpan = TimeSpan.FromMilliseconds(3), Value = 3 },
new() { TimeSpan = TimeSpan.FromMilliseconds(4), Value = 12 },
new() { TimeSpan = TimeSpan.FromMilliseconds(5), Value = 8 }
};
static string Formatter(TimeSpan value) => $"{value:fff}ms";
var series = new ISeries[]
{
new ColumnSeries<TimeSpanPoint> { Values = values }
};
var xAxis = new TimeSpanAxis(TimeSpan.FromMilliseconds(1), Formatter);
cartesianChart = new CartesianChart
{
Series = series,
XAxes = [xAxis],
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
}
}
The fff format shows only the milliseconds part of the duration; for longer spans use a format that includes the
seconds or minutes, or a property such as TotalMilliseconds.
Logarithmic axis
A LogarithmicAxis does not transform the data. The data must be mapped to its logarithm, and the axis turns each
exponent back into a value for the labels and the tooltips: with base 10, the value 3 on the axis is labeled
1,000.00. The base of the axis and the base of the mapper must be the same.
This sample registers a mapper for the LogarithmicPoint class that takes the base 10 logarithm of Y, and uses a
LogarithmicAxis with base 10 on the Y axis:

using System;
using System.Windows.Forms;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using LiveChartsCore.SkiaSharpView.Painting;
using LiveChartsCore.SkiaSharpView.WinForms;
using ViewModelsSamples.Axes.Logarithmic;
#pragma warning disable IDE1006 // Naming Styles
namespace WinFormsSample.Axes.Logarithmic;
public partial class View : UserControl
{
private readonly CartesianChart cartesianChart;
public View()
{
InitializeComponent();
Size = new System.Drawing.Size(50, 50);
var logBase = 10d;
// register the logarithmic point mapper
LiveCharts.Configure(config =>
config.HasMap<LogarithmicPoint>(
(logPoint, index) => new(logPoint.X, Math.Log(logPoint.Y, logBase))));
var values = new LogarithmicPoint[]
{
new(1, 1),
new(2, 10),
new(3, 100),
new(4, 1000),
new(5, 10000),
new(6, 100000),
new(7, 1000000),
new(8, 10000000)
};
var series = new ISeries[]
{
new LineSeries<LogarithmicPoint> { Values = values }
};
var yAxis = new LogarithmicAxis(logBase)
{
SeparatorsPaint = new SolidColorPaint(new SkiaSharp.SKColor(180, 180, 180, 100)),
SubseparatorsPaint = new SolidColorPaint(new SkiaSharp.SKColor(180, 180, 180, 100)) { StrokeThickness = 0.5f },
SubseparatorsCount = 9
};
cartesianChart = new CartesianChart
{
Series = series,
YAxes = [yAxis],
Location = new System.Drawing.Point(0, 0),
Size = new System.Drawing.Size(50, 50),
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Bottom
};
Controls.Add(cartesianChart);
}
}
namespace ViewModelsSamples.Axes.Logarithmic;
public class LogarithmicPoint(double x, double y)
{
public double X { get; set; } = x;
public double Y { get; set; } = y;
}
LiveCharts.Configure registers the mapper for every series of that type in the application. To use it on one series
only, set the Mapping property of the series instead:
Series = new ISeries[]
{
new LineSeries<LogarithmicPoint>
{
Values = values,
Mapping = (point, index) => new(point.X, Math.Log(point.Y, 10)) // mark
}
};
YAxes = new[]
{
new LogarithmicAxis(10) // mark
};
Math.Log returns double.NaN for negative values, which LiveCharts draws as a gap, and double.NegativeInfinity
for 0, which it does not. Map zeros to Coordinate.Empty if your data can contain them, see
NaN and Infinity.
Log labels and subseparators
The axis sets MinStep to 1, so the separators fall on whole exponents, the powers of the base. Its Labeler
returns Math.Pow(base, value) with the "N2" format. To change the format, set your own Labeler and convert the
exponent back the same way:
new LogarithmicAxis(10)
{
Labeler = value => Math.Pow(10, value).ToString("N0") // mark
}
Subseparators are spaced on a logarithmic scale too, closer together as they approach the next power of the base.
Set SubseparatorsCount to the base minus one, 9 for base 10 as in the sample, so they fall on 2, 3, 4... 9 times
each power. Subseparators are only drawn when SubseparatorsPaint is set.